tools:misc:xenlockprof: fix possible format string overflow
authorSeraphime Kirkovski <kirkseraph@gmail.com>
Tue, 4 Apr 2017 17:31:59 +0000 (19:31 +0200)
committerWei Liu <wei.liu2@citrix.com>
Wed, 5 Apr 2017 15:12:34 +0000 (16:12 +0100)
commitf49fa658b53580cf2ad354d2bf1796766cc11222
tree80ece693dec6818fb6d8faebc50ef80dad442fc1
parent88ad3208bb9a2e9516850d8480a5a323846dd0ed
tools:misc:xenlockprof: fix possible format string overflow

GCC7 complains about a possible overflow/truncation in xenlockprof.

xenlockprof.c: In function ‘main’:
xenlockprof.c:100:53: error: ‘%s’ directive writing up to 39 bytes into a
                         region of size between 17 and 37 [-Werror=format-overflow=]
             sprintf(name, "unknown type(%d) %d lock %s", data[j].type,
                                                     ^~
xenlockprof.c:100:13: note: ‘sprintf’ output between 24 and 83 bytes
                                             into a destination of size 60
             sprintf(name, "unknown type(%d) %d lock %s", data[j].type,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     data[j].idx, data[j].name);
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~

This increases the size of name to 100. Not the most scalable solution,
but certainly the "cheapest", as it doesn't add dependencies for
asprintf.

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/misc/xenlockprof.c